using UnityEngine;
using System;
using System.Collections;

[AddComponentMenu("TagMachine/Game Modes/Wolf Grow")]
public class GameModeWolfGrow : GameModeClassic 
{
	public float SizeGrow = 0.05f;

	// Initialization
	protected override void SetupFromPreferences()
	{
		base.SetupFromPreferences();

		if ( PlayerPrefs.HasKey( "SizeGrow" ) )
		{
			SizeGrow = PlayerPrefs.GetFloat( "SizeGrow" );
		}
	}

	protected override void ClearPreferences()
	{
		base.ClearPreferences();
		
		PlayerPrefs.DeleteKey( "SizeGrow" );
	}

	// Wolf Change
	public override void SwitchWolf( PlayerEntity _NewWolf )
	{
		// Old wolf take back its size
		Vector3 NewSize = Vector3.one;

		if ( CurrentWolf != null &&
			CurrentWolf != _NewWolf )
		{
			NewSize 								= CurrentWolf.transform.localScale + Vector3.one * SizeGrow;
			if ( InfectionMode )
			{
				CurrentWolf.transform.localScale 	= NewSize;
			}
			else
			{
				CurrentWolf.transform.localScale 	= Vector3.one;
			}
		}

		base.SwitchWolf( _NewWolf );

		// New wolf has new size
		CurrentWolf.transform.localScale 		= NewSize;
	}

	protected override void EndRound()
	{
		foreach ( PlayerEntity Player in m_Players )
		{
			Player.transform.localScale 		= Vector3.one;
		}

		base.EndRound();
	}
}
